import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@src': path.resolve(__dirname, 'src'),
    }
  },

  // 设置代理解决跨域问题
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:7001', //被代理的地址
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '') // 将/api重写为空
      }
    }
  },
})
